
package com.suarte.webapp.action;

import java.io.Serializable;
import java.util.List;
import java.util.Date;

import org.appfuse.service.GenericManager;
import com.suarte.core.Company;
import com.suarte.core.service.PaymentStatus;
import com.suarte.core.service.PaymentManager;

/**
 * @date   Feb 15, 2011
 * @author Gcastillo
 */
public class PaymentList extends BasePage implements Serializable {
    private PaymentManager paymentManager;
    private GenericManager<Company, Long> companyManager;
    private List payments;
    private Long id;
    private String description;
    private Date date;
    private List<Company> companies;
    private Company company;
    private String stStatus;

    public void setPaymentManager(PaymentManager paymentManager) {
        this.paymentManager = paymentManager;
    }

    public void setCompanyManager(GenericManager<Company, Long> companyManager) {
        this.companyManager = companyManager;
    }
    
    public PaymentList() {
        setSortColumn("id"); // sets the default sort column
    }

    public String execute() {
        PaymentStatus status = stStatus != null ? PaymentStatus.valueOf(stStatus) : null;
        payments = sort(paymentManager.findPayments(id, description, date, company, null, status));

        return "list";
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

     public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    public List getPayments() {
        return payments;
    }

    public void setPayments(List payments) {
        this.payments = payments;
    }

    public List<Company> getCompanies() {
        companies = companyManager.getAll();
        return companies;
    }

    public void setCompanies(List<Company> companies) {
        this.companies = companies;
    }

    public Company getCompany() {
        return company;
    }

    public void setCompany(Company company) {
        this.company = company;
    }
    
    public String getStStatus() {
        return stStatus;
    }

    public void setStStatus(String stStatus) {
        this.stStatus = stStatus;
    }
}